﻿
namespace Huioo.Learning.Agile.Payroll.Domain
{
    public class Employee
    {
        private readonly int empid;
        private string name;
        private readonly string address;
        //private PaymentClassification classification;
        //private PaymentSchedule schedule;
        //private PaymentMethod method;
        private Affiliation affiliation = new NoAffiliation();

        public Employee(int empid, string name, string address)
        {
            this.empid = empid;
            this.name = name;
            this.address = address;
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public string Address
        {
            get { return address; }
        }

        public PaymentClassification Classification { get; set; }
        public PaymentSchedule Schedule { get; set; }
        public PaymentMethod Method { get; set; }

        public Affiliation Affiliation
        {
            get { return affiliation; }
            set { affiliation = value; }
        }

        public bool IsPayDate(DateTime date)
        {
            return Schedule.IsPayDate(date);
        }

        public void Payday(Paycheck paycheck)
        {
            double grossPay = Classification.CalculatePay(paycheck);
            double deductions = Affiliation.CalculateDeductions(paycheck);
            double netPay = grossPay - deductions;

            paycheck.GrossPay = grossPay;
            paycheck.Deductions = deductions;
            paycheck.NetPay = netPay;
            Method.Pay(paycheck);
        }

        public DateTime GetPayPeriodStartDate(DateTime date)
        {
            return Schedule.GetPayPeriodStartDate(date);
        }
    }
}